#include<stdio.h>
const int maxn=1000;
int f[maxn][maxn],dp[maxn][maxn];
int main()
{
	int i,j,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		for(j=1;j<=i;j++)
			scanf("%d",&f[i][j]);
	for(j=1;j<=n;j++)
		dp[n][j]=f[n][j];
	for(i=n-1;i>0;i--){
		for(j=1;j<=n;j++){
			if(dp[i+1][j]>dp[i+1][j+1])
				dp[i][j]=dp[i+1][j]+f[i][j];
			else 
				dp[i][j]=dp[i+1][j+1]+f[i][j]; 
		}
	}
	printf("%d\n",dp[1][1]);
	return 0;
}
